<!DOCTYPE HTML>
<html class="x-admin-sm" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>设置新密码 -后台管理员</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" th:href="@{/asserts/css/adminlogin.css}">
    <link href="https://css.mafengwo.net/css/cv/css+login+login_v2:mobile+css+omc+login-omc+login-omc^ZlY^1550829726.css" rel="stylesheet" type="text/css"/>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css" rel="stylesheet" />
 	<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>
    <script th:src="@{/asserts/lib/layui/layui.js}" charset="utf-8"></script>
    <script th:src="@{/asserts/js/xadmin.js}"  type="text/javascript" ></script>
 	
</head>
<body class="editPassword-bg">
    <div class="wrapper">
        <div class="container">
            <div class="signup-forms">
                <div class="signup-box" style="top:80px;">
                    <div class="add-info">
                        <div class="hd">修改个人信息</div>
                            <div class="alert alert-info">
                            </div>
							<form method="post" class="layui-form" >
                            <div class="form-field">
                            	<input id="adminname" type="hidden" th:value=${adminname}>
                                <input id="name"  type="text" th:value=${adminname}  placeholder="昵称" lay-verify="nikename" autocomplete="off" class="" />
                                
                            </div>
                            <div class="form-field">
                                <input id="email"  type="email"   lay-verify="email" placeholder="新的邮箱" autocomplete="off" class="" />
                                
                            </div>
                            <div class="submit-btn">
                                <button  lay-submit lay-filter="update" type="submit" >修改</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
    $(function  () {
    	toastr.options = 
		{
	        positionClass: "toast-top-center",
	        closeButton: true,
	        timeOut:"1000",
	    };
    	
    	
    		$.ajax({
				type:"post",
				url: "/admin/aa04/getAdminEmail",
				data: JSON.stringify({adminname:$('#adminname').val()}),
			    contentType: "application/json",
			    dataType: "text",
			    async: false,
			    success: function (data) {
					$("#email").val(data);
			    },
			    error: function (e) {
			    	toastr.error('网络错误！');
			    }	
			});

    	

    	
        layui.use('form', function(){
          var form = layui.form;
          
          //检测是否符合规范
          form.verify({
              nikename: function(value) {
                  if (value.length < 5) {
                      return '昵称至少得5个字符';
                  }
              },
              
          });
          
        //监听提交
          form.on('submit(update)', function(data){
        	  $.ajax({
  				type:"post",
  				url: "/admin/aa04/updateInfo",
  				data: JSON.stringify({oldname:$("#adminname").val(),newname:$("#name").val(),email:$("#email").val()}),
  			    contentType: "application/json",
  			    dataType: "text",
  			    async: true,
  			    success: function (data) {
  			    	if(data=="修改成功")
  			    	{
  			    		toastr.success('修改成功!');
  			    		setTimeout(function () {
  			        		xadmin.close();
  		    	        	xadmin.father_reload();}, 1000);
  			    	}
  			    	else if(data=="修改失败")
  			    	{
  			    		toastr.warning('修改失败！');
  			    	}
  			    	else
  			    	{
  			    		toastr.warning('名称重复！');
  			    	}
  			    },
  			    error: function (e) {
  			    	toastr.error('网络错误！')
  			    }	
  			});  
        	  return false;
            });
          
          
    });
    })
    
    </script>
</body>
</html>
